<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Start of file administrator.php */
/* Location: ./cashflow/controllers/administrator.php */
class Administrator extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('departments'); /** load table departements **/ 
        $this->load->model('budgets'); /** load table budget **/ 
        $this->load->model('cashflow'); /** load table cashflow **/ 
        if(!$this->session->userdata('username')) /** restrict area if not acces to login page**/
			redirect('/',301); 
    }
    
    function rr_department(){
		$this->ws->set('title',lang('rr_department'));/** title page */
		$this->ws->set('username',$this->session->userdata('username')); /** username session */
		$this->ws->set('department',$this->session->userdata('dep')); /** departement session */
        
        /** coa to jenis **/
        $coa    =   $this->session->userdata('dep_budget');
        if($coa!="0" && $coa!="-") /** jika COA != ALL **/
            $jenis  =   "2"; /** Jenis=Detail**/
        else
            $jenis  =   "1"; /** Jenis=Rekap **/        
        
        if($this->session->userdata('dep_month')):
            $tomonth=   $this->session->userdata('dep_to_month');
            $month  =   $this->session->userdata('dep_month');
            $year   =   $this->session->userdata('dep_year');
            $dep    =   $this->session->userdata('dep_department');
            $type   =   $this->session->userdata('dep_type');
            $account=   $this->session->userdata('dep_budget');
        else:
            $tomonth=   '-'; 
            $month  =   '-';
            $year   =   '-';
            $dep    =   '-';
            $type   =   '-';
            $account=   '-';
        endif;    
        
        $this->ws->set('tomonth',$tomonth); /** variabel jenis **/
        $this->ws->set('month',$month); /** variabel dep_month **/
        $this->ws->set('year',$year); /** variabel dep_month **/
        $this->ws->set('type',$type); /** variabel dep_type **/
        $this->ws->set('account',$this->session->userdata('dep_budget')); /** variabel dep_account **/
        $this->ws->set('dep',$dep); /** variabel dep_month **/
        $this->ws->set('departement',$this->departments->getDataDepartment()); /** Get Data Table departement*/
        $this->ws->set('Accounts',$this->budgets->getAllAccount());
        $this->ws->set('coa',$this->budgets->getHeaderAccount($this->session->userdata('dep_budget'))); /** Get Data Table budget*/
        $this->ws->set('accounts',$this->budgets->getBudgetAccount()); /** Get Data Table budget*/
        $this->ws->set('budget',$this->budgets->getDataBudget('All')); /** Get Data Table budget*/
        $this->ws->set_theme('smooth'); /** set theme to administrator*/
		$this->ws->view('RR-department/index'); /** view layout to views/gas-disribution/index*/
	}
    
    function getBudgetDepartment(){
        /** Variabel Input Post **/
        $to_month   =   $this->input->post('to_month');/** transalate to variabel month**/
        $month      =   $this->input->post('month');/** transalate to variabel month**/
        $year       =   $this->input->post('year');/** transalate to variabel year**/
        $type       =   $this->input->post('type');/** transalate to variabel type**/
        $budget     =   $this->input->post('budget');/** transalate to variabel type**/
        $department =   $this->input->post('department'); /** transalate to variabel department**/
        /** Insert to Session Data **/
        $value  =   array(  'dep_month'         =>  $month,
                            'dep_to_month'      =>  $to_month, 
                            'dep_year'          =>  $year,
                            'dep_type'          =>  $type,
                            'dep_budget'        =>  $budget,
                            'dep_department'    =>  $department);
        $this->session->set_userdata($value);
        redirect('cashflow/administrator/rr_department',301); /** Redirect to Provider **/   
    }
    
    function getBudgetDepartmentReset(){
        /** Delete Session Data **/
        $value  =   array(  'dep_month'         =>  'dep_month',
                            'dep_to_month'      =>  'dep_to_month', 
                            'dep_year'          =>  'dep_year',
                            'dep_type'          =>  'dep_type',
                            'dep_budget'        =>  'dep_budget',
                            'dep_department'    =>  'dep_department');
        $this->session->unset_userdata($value);
        redirect('cashflow/administrator/rr_department',301); /** Redirect to RR Departement **/   
    }
      
}
/* Start of file administrator.php */
/* Location: ./cashflow/controllers/administrator.php */